<?php
/**
 * Created by PhpStorm.
 * User: yuanjie
 * Date: 16/5/25
 * Time: 上午10:24
 */

$api_service_path = __DIR__ . "/../../../api/";
ob_start();
require_once($api_service_path . "public/index.php");
ob_end_clean();

$items = DB::table('service_classification')->where('level',2)->get();
foreach ($items as $_item){
    $parent = DB::table('service_classification')->where('id',$_item->parent_id)->where('level',1)->first();
    $test = DB::table('test')->where('n2',$_item->name)->where('n1',$parent->name)->select(array('n3'))->get();
    foreach ($test as $_test)
    ServiceClassification::insert(
        array(
            'name' => $_test->n3,
            'parent_id' => $_item->id,
            'level' => 3,
            'status' => 1
        )
    );
}